<template>
  <div>
    <div>{{ msg }}</div>
    <button @click='update'>更新</button>
    <button @click='destroy'>销毁</button>
  </div>
</template>

<script>
export default {
  name: "TestLifeCircle",
  data() {
    return {
      msg: '生命周期'
    }
  },
  methods: {
    update: function () {
      this.msg = 'hello';
    },
    destroy: function () {
      this.$destroy();
    }
  },
  // 生命周期钩子函数
  beforeCreate: function () {
    console.log('beforeCreate');
  },
  created: function () {
    console.log('created');
  },
  beforeMount: function () {
    console.log('beforeMount');
  },
  mounted: function () {
    console.log('mounted');
  },
  beforeUpdate: function () {
    console.log('beforeUpdate');
  },
  updated: function () {
    console.log('updated');
  },
  beforeDestroy: function () {
    console.log('beforeDestroy');
  },
  destroyed: function () {
    console.log('destroyed');
  }
}
</script>

<style scoped>

</style>